#ifndef	_CLIP_RECT_H_
#define	_CLIP_RECT_H_

#include "frgui.h"
#define min(x,y)   ((x)>(y))? y:x
#define max(x,y)   ((x)>(y))? x:y

class ClipRect
{
public:
    HWND hWnd;	//< owner of this Rect
    ClipRect *next; //< link list of clip rects
    ClipRect *prev;
    Rect rect;

    ClipRect(HWND hWnd=0);/**< @brief constructor */
    ClipRect(Rect *rect);/**< @brief constructor */
    ~ClipRect();/**< @brief destructor */
    void operator delete(void *);
    void *operator new(unsigned int len);

    
    void setPosition(short x_offset, short y_offset);/**< @brief set position */

    int isZeroSize(const Rect *pRect);/**< @brief the size is zero */
    int isOverlap(const Rect *pRect);/**<@brief Be overwritten */
    int isInRect(short x, short y);/**< @brief Within the rectangle */
    int isOverCover(const Rect *rect);/**< @brief On the top floor */

    void listInsert(ClipRect *list, ClipRect *items);/**< @brief Insert the rectangular list */

    int intersectRect(Rect *newRect, const Rect *pRect);/**< @brief The intersection of the rectangle */
    ClipRect* removeRect(const Rect *pNewRect);	/**< @brief add a new rect to a rect, and devided into 1/4/5 small rects */
    ClipRect* uniteRect(const Rect *pRemoveRect);/**< @brief remove a rect, and form one large rect */
};


#endif

